package com.rickie.pvuv.domain;

import org.apache.flink.streaming.connectors.kafka.KafkaSerializationSchema;
import org.apache.kafka.clients.producer.ProducerRecord;

import javax.annotation.Nullable;

public class UserBehaviorSerializationSchema implements KafkaSerializationSchema<UserBehaviorEvent>  {
    private String topic;

    public UserBehaviorSerializationSchema(String topic) {
        super();
        this.topic = topic;
    }

    @Override
    public ProducerRecord<byte[], byte[]> serialize(UserBehaviorEvent userBehaviorEvent, @Nullable Long aLong) {
        return new ProducerRecord<>(topic, userBehaviorEvent.toString().getBytes());
    }
}
